home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1990-1992 Michael Davidson.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for any purpose and without fee is hereby
- * granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission
- * notice appear in supporting documentation.
- *
- * This software is provided "as is" without express or implied warranty.
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <string.h>
- #include <stdarg.h>
-
- #include "vg.h"
-
- extern char *cmdname;
-
- /*
- * fatal(err, format, ...) - print an error message and exit
- */
- void
- fatal(
- int err, /* system call error # or 0 */
- char *fmt, /* message format string */
- ... /* optional arguments */
- )
- {
- va_list args;
-
- cleanup();
-
- va_start(args, fmt);
- if (err < 0)
- (void) fprintf(stderr, "%s: internal error: ", cmdname);
- else
- (void) fprintf(stderr, "%s: fatal error: ", cmdname);
- (void) vfprintf(stderr, fmt, args);
- if (err > 0)
- (void) fprintf(stderr, ": %s\n", strerror(err));
- else
- (void) fprintf(stderr, "\n");
- va_end(args);
-
- exit(1);
- }
-